package com.yeban.javase.day13.test;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/23
 *
 * 喝啤酒问题，一瓶啤酒2元，两个空瓶子可以换一瓶啤酒，四个啤酒盖可以换一瓶啤酒，请问10元共可以喝多少瓶？
 */
public class Bear {

    public static int bear(int bottles, int empty, int cap) {
        if(empty < 2 && cap < 4) {
            return bottles;
        } else {
            int now = empty/2 + cap/4;
            bottles += now;
            empty = empty % 2 + now;
            cap = cap % 4 + now;
            return bear(bottles, empty, cap);
        }
    }

    public static void main(String[] args) {
        int n = 10 / 2;
        int nums = bear(n, n, n);
        System.out.println(nums);
    }
}
